from playwright.sync_api import sync_playwright


class BaseBrowser2(object):
    def __init__(self):
        super().__init__()
        self.playwright = sync_playwright().start()
        self.browser = self.playwright.chromium.launch(headless=False, slow_mo=50)

    def __del__(self):
        self.browser.close()
        self.playwright.stop()

    def page(self):
        page = self.browser.new_page()
        page.goto("http://whatsmyuseragent.org/")
        print(page.title())
        page.screenshot(path="example.png")

    def main(self):
        pass


def test1():
    BaseBrowser2().page()


if __name__ == '__main__':
    test1()
    print('end')
